home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / ulist.zip / ULIST.BAS next >
BASIC Source File  |  1991-02-06  |  20KB  |  279 lines

  1.         ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2.         ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3.         ':::                                                                 :::
  4.         ':::                                                                 :::
  5.         ':::    PROGRAM:        ULIST.BAS                                    :::
  6.         ':::    AUTHOR:         Mike Shaffer                                 :::
  7.         ':::    DATE:           Feb 2, 1991                                  :::
  8.         ':::    VERSION:        2.1                                          :::
  9.         ':::    PURPOSE:        Shows a userlist on Novell with total        :::
  10.         ':::                    elapsed time logged-in.                      :::
  11.         ':::    REVISIONS:      Feb 6, 1991: Improved structure of source    :::
  12.         ':::                                 for general release (V2.0-2.1)  :::
  13.         ':::                                                                 :::
  14.         ':::                                                                 :::
  15.         ':::    NOTES:          This program assumes you're using PDQ from   :::
  16.         ':::                    Crescent Software. If not (shame on you!)    :::
  17.         ':::                    than you can modify the interrupt call to    :::
  18.         ':::                    use INT86 as provided with QuickBASIC, and   :::
  19.         ':::                    take out the reference to PDQDECL.BAS.       :::
  20.         ':::                    Also change: PDQVALx() references to VAL()   :::
  21.         ':::                                 PDQCPRINT references to PRINT   :::
  22.         ':::                                                                 :::
  23.         ':::                    Compile using:                               :::
  24.         ':::                                                                 :::
  25.         ':::                         BC ulist/o/s;                           :::
  26.         ':::                         LINK /NOD/NOE ulist,,,pdq[386].lib      :::
  27.         ':::                                                                 :::
  28.         ':::                    or similar...                                :::
  29.         ':::                                                                 :::
  30.         ':::                                                                 :::
  31.         ':::                                                                 :::
  32.         ':::                                                                 :::
  33.         ':::  Author  is not responsible for any damages resulting from use  :::
  34.         ':::  or  inability to use this program.  The entire responsibility  :::
  35.         ':::  for use of this program is with the user.                      :::
  36.         ':::                                                                 :::
  37.         ':::                                                                 :::
  38.         ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  39.         ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  40.         '
  41.         '                                               '   PDQ declarations
  42.         '                                               '   PDQ declarations
  43.         '$include: 'pdqdecl.bas'                        ' Crescent Software's
  44.         '                                               '   PDQ declarations
  45.         '                                               '
  46.         dim shared regs as regtype                      ' Define a struct for
  47.         '                                               '   interrupt usage
  48.         '                                               '
  49.         common shared year%,month$,day$,_               ' Share vars
  50.                       hours$,mins$,reply$               '
  51.         '                                               '
  52.         declare SUB SINFO(node%,result%)                ' SUB to get node info
  53.         '                                               '
  54.         '                                               '
  55.         def fnCALCDATE&(year,month,days)=_              ' Function to obtain
  56.               ((month-1)*28)+_                          '   the 3-digit day
  57.               pdqvall&(MID$("000303060811131619212426",_'   of year value (from
  58.               (month - 1) * 2 + 1, 2))-_                '   1 to 365/366 if leap
  59.               ((month>2) AND ((year AND NOT -4)=0))+_   '   year) given mm, dd,
  60.               days                                      '   and 4-digit yy.
  61.         '                                               '
  62.         today& = fncalcdate&(pdqvall&(mid$(date$,7,4)),_' Get today's day number
  63.                              pdqvall&(mid$(date$,1,2)),_'   from 1-365 (or 366
  64.                              pdqvall&(mid$(date$,4,2))) '   if a leap year!)
  65.         '                                               '
  66.         now& = (today&*86400)+_                         '
  67.                (pdqvall&(left$(time$,2))*3600)+_        '
  68.                (pdqvall&(mid$(time$,4,2))*60)           ' Calculate current time
  69.         '                                               '   from the beginning
  70.         '                                               '   of year in seconds.
  71.         '                                               '   ±59 seconds
  72.         '                                               '
  73.         '                                               '
  74.         ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  75.         ':::       Display the welcome and some titles for the table         :::
  76.         ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  77.         '                                               '
  78.         '                                               '
  79.         '                                               '
  80.         color 7,0                                       '   set 'normal'
  81.         print "■ ULIST ■ Version 2.1 ■ Copyright *c* 1991, Mike Shaffer"
  82.         color 14,0:pdqcprint "■",csrlin-1,1             ' Jazz it up with a 
  83.         pdqcprint "■",csrlin-1,9                        '   bit of color!
  84.         pdqcprint "■",csrlin-1,23                       '
  85.         color 7,0 : pdqcprint " ",csrlin,2              '
  86.         '                                               '
  87.         '                                               '
  88.         '                                               '
  89.         ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  90.         ':::                Now we really get down to business!              :::
  91.         ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  92.         '                                               '
  93.         '                                               '
  94.         '                                               '
  95.         pse% = 0                                        ' Clear PAUSE flag
  96.         if instr(ucase$(command$),"/P") then            ' Did user want a pause?
  97.            pse% = -1                                    '   YES: Set PAUSE flag
  98.            lct%   =  0                                  '   clear line count
  99.         end if                                          '
  100.         '                                               '
  101.         '                                               '
  102.         if instr(ucase$(command$), "?") or_             ' Did user want help?
  103.            instr(ucase$(command$),"/H") then            ' Did user want help?
  104.               goto HELP                                 '   YES: So give it
  105.         end if                                          '
  106.         '                                               '
  107.         '                                               '
  108.         '                                               '
  109.         regs.ax = &h7A00                                ' Check to see if we
  110.         '                                               '   are running Novell!
  111.         interrupt &h2F,regs                             ' Do interrupt
  112.         if (regs.ax AND &hFF) <> &hFF then              ' Whoops! We're not!
  113.            color 12,0                                   '   Error indication
  114.            print : print                                '
  115.            pdqcprint "Not running Novell Netware.",_    '
  116.                      csrlin,1                           '   Show error
  117.            color 7,0                                    '   back to 'normal'
  118.            goto HELP                                    '   Show help screen!
  119.         end if                                          '
  120.         '                                               '
  121.         regs.ax = &hDC00                                ' Function to get this
  122.         interrupt &h21,regs                             '   node's address
  123.         lcal% = regs.ax and &hFF                        ' Contained in AL
  124.         '                                               ' INTERESTING NOTE:
  125.         '                                               '   I tried to name
  126.         '                                               '   this variable
  127.         '                                               '   LOCAL%, but was
  128.         '                                               '   informed by QB that
  129.         '                                               '   it was an advanced
  130.         '                                               '   feature (a reserved
  131.         '                                               '   word).
  132.         '                                               '
  133.         '                                               '
  134.         SINFO lcal%,result%                             ' Get port info
  135.         '                                               ' OK, we're on a Novell
  136.         '                                               '   network (IPX is 
  137.         '                                               '   loaded) but are we
  138.         '                                               '   logged in?
  139.         if not result% then                             ' Whoops! Not logged in!
  140.            color 12,0                                   '   Error indication
  141.            print : print                                '
  142.            pdqcprint "Not logged-in to any server.",_   '
  143.                      csrlin,1                           '   Show error
  144.            color 7,0                                    '   back to 'normal'
  145.            goto HELP                                    '   Show help screen!
  146.         end if                                          '
  147.         '                                               '
  148.         '                                               '
  149.         '                                               '
  150.         '                                               '
  151.         print "Station  User-ID      Time/Date Logged In     Elapsed time on system"
  152.         print "-------------------------------------------------------------------------"
  153.         for x% = 1 to 255                               ' Display <= 255 nodes
  154.            '                                            '
  155.            SINFO x%,result%                             '
  156.            if result% then                              '
  157.            '                                            '
  158.               print right$("000"+str$(x%),3);space$(7); ' Print station #
  159.               if x% = lcal% then                        ' Is it me?
  160.                  color 14,0                             '   YES, so:
  161.                  pdqcprint "-->",csrlin,5               '     display a color
  162.                  color 7,0                              '     identifier
  163.               end if                                    '
  164.               print mid$(reply$,9,12);                  ' Show ID name
  165.               print " ";hours$":"mins$"  ";             ' Show time logged in
  166.               print month$"/"day$"/"year%;"   ";        ' Show date logged in
  167.               '                                         ' Now we determine how
  168.               '                                         '   long this node has
  169.               '                                         '   been 'logged-in'
  170.               ldate& = fncalcdate&(year%,_              ' Calculate 'logged-in'
  171.                                    pdqvall&(month$),_   '    date's 3-digit day
  172.                                    pdqvall&(day$))      '    of year value
  173.               ltime& = (pdqvall&(hours$)*3600)+_        ' Calculate elapsed time
  174.                        (pdqvall&(mins$)*60)             '   in seconds (today)
  175.               lthen& = (ldate&*86400) + ltime&          ' Calculate elapsed time
  176.               '                                         '   in seconds from log-
  177.               '                                         '   in date
  178.               diff&  = now& - lthen&                    ' Get difference
  179.               '                                         '
  180.               '                                         ' Now we can get the time
  181.               '                                         '   in human readable form
  182.               '                                         '   (hh:mm:ss) by using 
  183.               '                                         '   integer math only...
  184.               hrs& = diff&\3600:diff& = diff& mod 3600  ' Get hours
  185.               mns& = diff&\60:diff& = diff& mod 60      ' Get minutes
  186.               dys& = hrs&\24:hrs& = hrs& mod 24         ' Get days, modify hours
  187.               '                                         '
  188.               if dys& = 0 then                          ' Print # of days this
  189.                  print "           ";                   '   node has been online
  190.               elseif dys& = 1 then                      '    .
  191.                  print "   1 day,  ";                   '    .
  192.               else                                      '    .
  193.                  print right$(space$(4)+_               '    .
  194.                        str$(dys&),4)" days, ";          '    .
  195.               end if                                    '    .
  196.               if hrs& = 0 then                          ' Print # of hours this
  197.                  print "        ";                      '   node has been online
  198.               elseif hrs& = 1 then                      '    .
  199.                  print " 1 hr,  ";                      '    .
  200.               else                                      '    .
  201.                  print right$(space$(2)+_               '    .
  202.                        str$(hrs&),2)" hrs, ";           '    .
  203.               end if                                    '    .
  204.               print right$(space$(2)+str$(mns&),2)" min"' Print # of minutes
  205.               '                                         '   this node online
  206.               '                                         '
  207.               '                                         '
  208.               if pse% then                              ' Is PAUSE flag on?
  209.                  lct% = lct% + 1                        '   INC line count
  210.                  if lct% = 20 then                      '   at limit?
  211.                     print "(Press a key for more)";     '   YES: show prompt
  212.                     an$ = input$(1)                     '        wait for key
  213.                     lct% = 0                            '        clear count
  214.                     locate csrlin,1                     '        go to BOL
  215.                     print space$(20);                   '        clear prompt
  216.                     locate csrlin,1                     '        go to BOL
  217.                  end if                                 '   done
  218.               end if                                    '
  219.               '                                         '
  220.               '                                         '
  221.            else                                         ' OTHERWISE (null)
  222.               mt% = mt% + 1                             '   Increment null count
  223.               if mt% = 20 then x% = 255                 '   if over 20 nulls
  224.               '                                         '     have been seen,
  225.               '                                         '     assume we're done!
  226.            end if                                       '
  227.         next                                            ' Continue until done
  228.         '                                               '
  229.         '                                               '
  230.         end                                             '
  231.         '                                               '
  232.         '                                               '
  233.         '                                               '
  234. HELP:                                                   '
  235.         print                                           '
  236.         print                                           '
  237.         print "ULIST displays a list of users currently on your Novell Network."
  238.         print "In addition to Novell's USERLIST command, ULIST also shows the total"
  239.         print "elapsed time on the net by each user. The only options for ULIST are:"
  240.         print                                           '
  241.         print "        /H or /?  =  This help screen"
  242.         print "        /P        =  Pause on full screens"
  243.         print
  244.         print                                           '
  245.         print                                           '
  246.         print "┌"string$(77,"─")"┐"
  247.         print "│ To report problems or submit suggestions for improvement, call Mike Shaffer │"
  248.         print "│          at (214) 855-5200 (voice) or (214) 340-6896 (SOS-BBS).             │"
  249.         print "└"string$(77,"─")"┘"
  250.         print                                           '
  251.         print                                           '
  252.         end                                             '
  253.         '                                               '
  254.         '                                               '
  255.         '                                               '
  256.         '                                               '
  257.         sub SINFO(node%,result%) static                 '
  258.            result%  = 0                                 ' Clear result
  259.            request$ = mki$(61) + chr$(22) + chr$(node%) ' Set up interrupt req
  260.            reply$   = ""                                ' Erase string (PDQ)
  261.            reply$   = space$(63)                        ' Set up receiver
  262.            regs.ax  = &hE300                            ' Define interrupt/func
  263.            regs.si  = sadd(request$)                    ' Address of request
  264.            regs.di  = sadd(reply$)                      ' Address for reply
  265.            interrupt &h21,regs                          ' Do it!
  266.            '                                            '
  267.            if midchar%(reply$,9)<> 0 and_               ' Not null?
  268.               midchar%(reply$,9)<>32 then               ' Not space?
  269.               result% = -1                              ' Show good results!
  270.               year%  = (1900 + (cvi(mid$(reply$,57,2)) and &hFF))
  271.               Month$ = right$("00"+str$((cvi(mid$(reply$,58,2)) and &HFF)),2)
  272.               Day$   = right$("00"+str$((cvi(mid$(reply$,59,2)) and &HFF)),2)
  273.               Hours$ = right$("00"+str$((cvi(mid$(reply$,60,2)) and &HFF)),2)
  274.               Mins$  = right$("00"+str$((cvi(mid$(reply$,61,2)) and &HFF)),2)
  275.               '                                         '
  276.            end if                                       '
  277.         end sub                                         '
  278.  
  279.